/*	Problem: http://codeforces.ru/problemset/problem/100/D
	  Verdict: Accepted
*/
int main()
{
        int n = (int)Stdio.stdin->gets();
        string a = Stdio.stdin->gets();
        string b = Stdio.stdin->gets();
        
        int la = strlen(a);
        int lb = strlen(b);
        
        int d = 0;
        
        int i = 0;
        while ((i < la) && (i < lb) && (a[i] == b[i]))
                i++;
        
        d = min(la - i, lb - i) * 2 + abs(la - lb);
        
        if (d <= n)
                write("Yes");
        else
                write("No");
                
        return 0;
}